<template>
    <div>
      <form action="">
        <input type="text" v-model="name">用户名
        <input type="text" v-model="password">密码
        <button @click="on_login">登录</button>
      </form>
    </div>
</template>

<script>
  import axios from 'axios'
    export default {
        name: "login",
        data(){
          return{
            name:'',
            password:''
          }
        },
        methods:{
          on_login(){
            axios({
            url:'http://127.0.0.1:8000/login/',
            method:'POST',
            data:{'name':this.name,'password':this.password}

          }).then(res=>{
            console.log(res);
            localStorage.setItem('name',this.name);
            this.$router.push('/show')
          })
          }

        }
    }
</script>

<style scoped>

</style>
